home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / etc / init.d / apport < prev    next >
Encoding:
Text File  |  2007-04-19  |  3.0 KB  |  130 lines

  1. #! /bin/sh
  2.  
  3. ### BEGIN INIT INFO
  4. # Provides:          apport
  5. # Required-Start:    $local_fs $remote_fs
  6. # Required-Stop:     $local_fs $remote_fs
  7. # Default-Start:     2 3 4 5
  8. # Default-Stop:      S 0 1 6
  9. # Short-Description: automatic crash report generation
  10. ### END INIT INFO
  11.  
  12. PATH=/bin
  13. DESC="automatic crash report generation"
  14. NAME=apport
  15. AGENT=/usr/share/apport/apport
  16. SCRIPTNAME=/etc/init.d/$NAME
  17.  
  18. # Exit if the package is not installed
  19. [ -x "$AGENT" ] || exit 0
  20.  
  21. # read default file
  22. enabled=1
  23. [ -e /etc/default/$NAME ] && . /etc/default/$NAME || true
  24.  
  25. [ "$enabled" = "1" ] || exit 0
  26.  
  27. # Define LSB log_* functions.
  28. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
  29. . /lib/lsb/init-functions
  30.  
  31. #
  32. # Function that starts the daemon/service
  33. #
  34. do_start()
  35. {
  36.     # Return
  37.     #   0 if daemon has been started
  38.     #   1 if daemon was already running
  39.     #   2 if daemon could not be started
  40.     [ -e /var/crash ] || mkdir -p /var/crash
  41.         chmod 1777 /var/crash
  42.  
  43.     # edgy support: Ubuntu specific kernel patch
  44.     PROCFILE=/proc/sys/kernel/crashdump-helper
  45.     [ -e "$PROCFILE" ] || PROCFILE=/proc/sys/kernel/crashdump
  46.     if [ -e "$PROCFILE" ]; then
  47.         if [ "`cat $PROCFILE`" = "$AGENT" ]; then
  48.         return 1
  49.         else
  50.         echo $AGENT > $PROCFILE || return 2
  51.         return 0
  52.         fi
  53.     fi
  54.  
  55.     # 'pipe in core_pattern' support in feisty/future upstream kernels
  56.     if [ "`dd if=/proc/sys/kernel/core_pattern count=1 bs=1 2>/dev/null`" = "|" ]; then
  57.         return 1
  58.     else
  59.         echo "|$AGENT" > /proc/sys/kernel/core_pattern
  60.     fi
  61. }
  62.  
  63. #
  64. # Function that stops the daemon/service
  65. #
  66. do_stop()
  67. {
  68.     # Return
  69.     #   0 if daemon has been stopped
  70.     #   1 if daemon was already stopped
  71.     #   2 if daemon could not be stopped
  72.     #   other if a failure occurred
  73.  
  74.     # edgy support: Ubuntu specific kernel patch
  75.     PROCFILE=/proc/sys/kernel/crashdump-helper
  76.     [ -e "$PROCFILE" ] || PROCFILE=/proc/sys/kernel/crashdump
  77.     if [ -e "$PROCFILE" ]; then
  78.         if [ -z "`cat $PROCFILE`" ]; then
  79.         return 1
  80.         else
  81.         echo '' > $PROCFILE || return 3
  82.         return 0
  83.         fi
  84.     fi
  85.  
  86.     # 'pipe in core_pattern' support in feisty/future upstream kernels
  87.     if [ "`dd if=/proc/sys/kernel/core_pattern count=1 bs=1 2>/dev/null`" != "|" ]; then
  88.         return 1
  89.     else
  90.         echo "core" > /proc/sys/kernel/core_pattern
  91.     fi
  92. }
  93.  
  94. # Set max core dump size, if specified in the default file
  95. set_maxsize()
  96. {
  97.     if [ -n "$maxsize" ] && [ -e /proc/sys/kernel/crashdump-size ]; then
  98.     echo "$maxsize" > /proc/sys/kernel/crashdump-size
  99.     fi
  100. }
  101.  
  102. case "$1" in
  103.   start)
  104.     [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC:" "$NAME"
  105.     do_start
  106.     case "$?" in
  107.         0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  108.         2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  109.     esac
  110.     set_maxsize
  111.     ;;
  112.   stop)
  113.     [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC:" "$NAME"
  114.     do_stop
  115.     case "$?" in
  116.         0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  117.         2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  118.     esac
  119.     ;;
  120.   restart|reload|force-reload)
  121.     set_maxsize
  122.     ;;
  123.   *)
  124.     echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  125.     exit 3
  126.     ;;
  127. esac
  128.  
  129. :
  130.